package com.qxgltj.qxgl.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import lombok.Data;
@Data
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
@Entity
@GenericGenerator(name = "jpa-uuid",strategy = "uuid")
public class Modules {
    @Id
    @GeneratedValue
private Integer id;//模块编号
private String name;//模块名称
private Integer parentId;//父模块编号
private String path;//模块路径
private Integer weight;//权重

@ElementCollection//表示该属性是映射，不是参数不需要创建字段
private List<Modules> children; 
/* @JsonIgnore
@ManyToMany(cascade = CascadeType.REFRESH,mappedBy = "moduleslist",fetch =FetchType.LAZY)
private List<Roles>roleslist; */
@JsonIgnore
@ManyToMany(fetch = FetchType.EAGER,mappedBy = "moduleslist",cascade =CascadeType.REFRESH)
@NotFound(action = NotFoundAction.IGNORE)//如果找不到就跳过
private List<Roles> moduleRoleslist;//角色表集合
}